/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.account.Key.CalendarResourceBy;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AdminConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.cs.account.AttributeClass;
/*    */ import com.zimbra.cs.account.CalendarResource;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*    */ import com.zimbra.soap.JaxbUtil;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import com.zimbra.soap.admin.message.GetCalendarResourceRequest;
/*    */ import com.zimbra.soap.admin.type.CalendarResourceSelector;
/*    */ import com.zimbra.soap.admin.type.CalendarResourceSelector.CalendarResourceBy;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ import java.util.Set;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class GetCalendarResource
/*    */   extends AdminDocumentHandler
/*    */ {
/* 42 */   private static final String[] TARGET_RESOURCE_PATH = { "calresource" };
/*    */   
/* 44 */   protected String[] getProxiedResourceElementPath() { return TARGET_RESOURCE_PATH; }
/*    */   
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */   public boolean domainAuthSufficient(Map context)
/*    */   {
/* 52 */     return true;
/*    */   }
/*    */   
/*    */ 
/*    */ 
/*    */ 
/*    */   public boolean defendsAgainstDelegateAdminAccountHarvesting()
/*    */   {
/* 60 */     return true;
/*    */   }
/*    */   
/*    */   public Element handle(Element request, Map<String, Object> context)
/*    */     throws ServiceException
/*    */   {
/* 66 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 67 */     Provisioning prov = Provisioning.getInstance();
/* 68 */     GetCalendarResourceRequest req = (GetCalendarResourceRequest)JaxbUtil.elementToJaxb(request);
/* 69 */     boolean applyCos = !Boolean.FALSE.equals(req.getApplyCos());
/* 70 */     Key.CalendarResourceBy calresBy = req.getCalResource().getBy().toKeyCalendarResourceBy();
/* 71 */     String value = req.getCalResource().getKey();
/*    */     
/* 73 */     CalendarResource resource = prov.get(calresBy, value);
/* 74 */     defendAgainstCalResourceHarvesting(resource, calresBy, value, zsc, Rights.Admin.R_getCalendarResourceInfo);
/*    */     
/* 76 */     AdminAccessControl aac = checkCalendarResourceRight(zsc, resource, AdminRight.PR_ALWAYS_ALLOW);
/*    */     
/* 78 */     Element response = zsc.createElement(AdminConstants.GET_CALENDAR_RESOURCE_RESPONSE);
/* 79 */     Set<String> reqAttrs = getReqAttrs(req.getAttrs(), AttributeClass.calendarResource);
/* 80 */     ToXML.encodeCalendarResource(response, resource, applyCos, reqAttrs, aac.getAttrRightChecker(resource));
/*    */     
/* 82 */     return response;
/*    */   }
/*    */   
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*    */   {
/* 87 */     relatedRights.add(Rights.Admin.R_getCalendarResource);
/* 88 */     notes.add(String.format("Attributes that are not allowed to be get by the authenticated admin will be returned as <a n=\"{attr-name}\" pd=\"1\"/>.To allow an admin to get all attributes, grant the %s right", new Object[] { Rights.Admin.R_getCalendarResource.getName() }));
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/GetCalendarResource.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */